/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-08-21 11:26:12
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-08-21 11:29:48
 * @FilePath: /vue3-uniapp/src/service/useOrderCase.ts
 */
import { readOrderDetail } from '@/api/orderCase';
import type { OrderDetail } from '@/typings/api/orderCase';

export const useOrderCase = () => {
    const detail = ref<OrderDetail>();
    const loading = ref(false);
    const getDetail = (orderId: number) => {
        if (loading.value) return Promise.reject();
        loading.value = true;
        return readOrderDetail(orderId)
            .then((res) => {
                detail.value = res?.data;
                return res;
            })
            .finally(() => {
                loading.value = false;
            });
    };

    return {
        detail,
        loading,
        getDetail
    };
};
